package com.biz.primus.ms.product.degraded;

import com.biz.primus.base.enums.PromotionTypeEnum;
import com.biz.primus.base.vo.ProductPromotionTagRespVo;
import com.biz.primus.base.vo.ProductSpecialOfferPromotionRespVo;
import com.biz.primus.base.vo.PromotionBasicInfoVo;
import com.biz.primus.model.promotion.vo.req.*;
import com.biz.primus.ms.product.feign.PromotionFeignClient;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jiangnan
 * @Description:
 */
@Slf4j
@Component
public class DegradedPromotionFeignClient implements PromotionFeignClient {
    @Override
    public List<ProductSpecialOfferPromotionRespVo> getProductSpecialOfferPromotion(MultiProductSpecialOfferPriceReqVo reqVo) {
        // TODO: 2017/11/23 模拟
        List<Long> productIds = reqVo.getProductIds();
        List<ProductSpecialOfferPromotionRespVo> respVos = Lists.newArrayList();
        for (Long index:productIds){
            ProductSpecialOfferPromotionRespVo vo = new ProductSpecialOfferPromotionRespVo();
            vo.setSpecialOfferPrice(100);
            respVos.add(vo);
        }
        return respVos;
    }

    @Override
    public ProductSpecialOfferPromotionRespVo getProductSpecialOfferPromotion(SingleProductSpecialOfferPriceReqVo reqVo) {
        ProductSpecialOfferPromotionRespVo respVo = new ProductSpecialOfferPromotionRespVo();
        respVo.setSpecialOfferPrice(100);
        respVo.setPurchaseQuantityLimit(1);
        return respVo;
    }

    @Override
    public List<PromotionBasicInfoVo> getProductPromotions(ProductPromotionReqVo reqVo) {
        List<PromotionBasicInfoVo> respVos = Lists.newArrayList();
        PromotionBasicInfoVo vo = new PromotionBasicInfoVo();
        vo.setId(123L);
        vo.setName("满减");
        vo.setDescription("慢1块减0元");
        vo.setPromotionType(PromotionTypeEnum.DISCOUNT);
        respVos.add(vo);
        return respVos;
    }

    @Override
    public List<ProductPromotionTagRespVo> getProductPromotionTags(ProductPromotionTagReqVo reqVo) {
        List<ProductPromotionTagRespVo> respVOs = Lists.newArrayList();
        List<ProductPromotionTagReqItemVo> items = reqVo.getItems();
        for (int i=0;i<items.size();i++){
            ProductPromotionTagRespVo productPromotionTagRespVo = new ProductPromotionTagRespVo();
            productPromotionTagRespVo.setProductId(123L);
            productPromotionTagRespVo.setPromotionTags(new ArrayList<String>(){{add("大减价");add("特卖会");}});
            respVOs.add(productPromotionTagRespVo);
        }
        return respVOs;
    }
}
